package fox.framework.rpc.client;

import java.util.List;

/**
 * @author cuichao
 * @Description: AbstractRpcRegister
 * @Date: create in 2021/1/9 20:02
 */
abstract class AbstractRpcRegister implements RpcRegister {

    protected Registrable registrable;

    public void setRegistrable(Registrable registrable) {
        this.registrable = registrable;
    }


    @Override
    public void fetch(List<String> metaSpaces) {
        List<RegisterNodeInfo> infoList = fetchNodeData(metaSpaces);
        for (RegisterNodeInfo info : infoList) {
           registrable.updateNode(info.getMetaspace(),info.getAddress(),info.getStatus());
        }
    }

    /**
     * 根据客户端的元数据空间列表获取到相应的元数据节点信息
     * @param metaSpaces
     * @return
     */
    protected abstract List<RegisterNodeInfo> fetchNodeData(List<String> metaSpaces);



}
